<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="app" uri="http://www.wanrenhui.com"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<%@include file="/res/include/base-head.jsp"%>
<%@include file="/res/include/jquery-easyui.jsp"%>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/res/js/homemaking/homemakingBase.js"></script>
<style>
.workno {
	display: inline-block;
	width: 54px;
	height: 26px;
	background-color: #ffbd93;
	border-left: 1px solid sandybrown;
	border-bottom: 1px solid sandybrown;
	text-align: center;
	line-height: 26px;
	color: #fff;
}

.workyes {
	display: inline-block;
	width: 54px;
	height: 26px;
	background-color: #dbf1c7;
	border-left: 1px solid sandybrown;
	border-bottom: 1px solid sandybrown;
	text-align: center;
	line-height: 26px;
}

.workMonth {
	display: inline-block;
	height: 20px;
	background-color: #D8D8D8;
	text-align: center;
	float: left;
	border-left: 1px solid red
}

.work {
	clear: both
}

.work span {
	float: left;
}

.person {
	width: 120px;
	display: inline-block;
	text-align: right
}

.itemDate .workyes {
	background: #fff;
}

.itemWeek {
	margin-bottom: 20px;
}

.itemWeek .workno, .itemWeek .workyes {
	color: #000;
}
</style>

</head>
<body>
	<div>
		<c:forEach items="${dateList}" var="m">
		<div class="work itemMonth">
			<span class="person">日期</span>
			<span class="workMonth cred" style="width: 824px">${m.dateStr} ${m.weekDay}</span>
		</div>
		<div class="work itemDate">
			<span class="person">时间</span>
			<span class="workyes">7:00</span>
			<span class="workyes">8:00</span>
			<span class="workyes">9:00</span>
			<span class="workyes">10:00</span>
			<span class="workyes">11:00</span>
			<span class="workyes">12:00</span>
			<span class="workyes">13:00</span>
			<span class="workyes">14:00</span>
			<span class="workyes">15:00</span>
			<span class="workyes">16:00</span>
			<span class="workyes">17:00</span>
			<span class="workyes">18:00</span>
			<span class="workyes">19:00</span>
			<span class="workyes">20:00</span>
			<span class="workyes">21:00</span>
		</div>
		<div class="work date item0">
			<span class="person">&nbsp;</span>
			<c:forEach items="${m.workList}" var="w">
				<c:choose>
					<c:when test="${w.type==0}"><span class="${w.classStr}" onclick="addRestTime('${m.dateStr}','${w.hour}')">${w.typeStr}</span></c:when>
					<c:when test="${w.type==2 || w.type==3}"><span class="${w.classStr}" onclick="deleRestTime('${m.dateStr} ${w.hour}','${w.timeId}')">${w.typeStr}</span></c:when>
					<c:otherwise><span class="${w.classStr}">${w.typeStr}</span></c:otherwise>
				</c:choose>
			</c:forEach>
		</div>
		<br /><br />
		</c:forEach>
	</div>
</body>
</html>
<script type="text/javascript">
function addRestTime(date,hour) {
	var msg = '';
	if ('${isRestMode}' == '1') {
		msg = '确定要把'+date+' '+hour+'设为休息吗';
	} else {
		msg = '确定要把'+date+' '+hour+'设为上班吗';
	}
	$.messager.confirm('信息提示', msg, function (success) {
		if (!success) {
			return;
		}
		var url = contextPath + '/homemaking/time/addRestTime';
		
		$.postJson(url, {'baseId': '${baseId}','serviceDateStr':date,'serviceHourStr':hour}, function (result) {
			if (result.code == 1) {
				top.addTab("time${baseId}",'${nick}的时间', contextPath+'/homemaking/time/list/${baseId}');
			} else {
				top.showInfo(result.msg);
			}
		});
	});
}
function deleRestTime(hour,timeId) {
	var msg = '';
	if ('${isRestMode}' == '1') {
		msg = '确定要取消'+hour+'休息吗';
	} else {
		msg = '确定要取消'+hour+'上班吗';
	}
	$.messager.confirm('信息提示', msg, function (success) {
		if (!success) {
			return;
		}
		var url = contextPath + '/homemaking/time/deleRestTime';
		$.postJson(url, {'id': timeId}, function (result) {
			if (result.code == 1) {
				top.addTab("time${baseId}",'${nick}的时间', contextPath+'/homemaking/time/list/${baseId}');
			} else {
				top.showInfo(result.msg);
			}
		});
	});
}
</script>